const fs = require('fs')
const path = require('path')

// 获取文件路径
const filePath = filename => path.join(__dirname, filename);

// 读取文件内容并解析为JSON
module.exports.readFile = filename => JSON.parse(fs.readFileSync(filePath(filename), 'utf-8'));

// 将数据写入文件
module.exports.writeFile = (filename, data) => {
    fs.writeFileSync(filePath(filename), JSON.stringify(data, null, 2), 'utf-8');
}